{% extends "base_site.html" %}
{% load i18n common_tags developer_tags version_control_tags %}

{% block extrahead %}
    {{ block.super }}
    {% include_media %}
{% endblock %}

{% block title %}Version Control: {{block.super}}{% endblock %}
{% block content_title %}
    {{project}} {{to_revision}} {{root.abspath_verbose}}

{% endblock %}
{% block nav_content %}
<dl class="menu">
    <dt><label>In this revision</label></dt>
    <dd>
    <ol>
        <li class="item"><a href="#committed_files">Committed Files</a></li>
        <li class="item"><a href="#latest_dialog">Latest Dialog</a></li>
    </ol>
    </dd>
</dl>

<div class="help">
    <p class"join">
        Add dialog to this file, `<span class="code">{{to_revision}}</span>`.
        Just insert code in your email message like this.
        <pre class="box code">{{to_revision.reference_tag}}</pre>
    </p>
    <p class"join">
    Or,
        add dialog to this directory, `<span class="code">{{root.abspath_verbose}}</span>`.
        Just insert code name in your email message like this.
        <pre class="box code">{{root.reference_tag}}</pre>
    </p>
</div>
{% endblock %}

{% block content %}
<div class="table navigate-revision">
    <div class="row">
        <div class="cell" style="width: 50%; text-align: left; border:0;">
        ❮
        {% if to_revision.previous %}
{% revision info=info path=root to_revision=to_revision.previous.number %}
        {% else %}
        None
        {% endif %}
        </div>
        <div class="cell" style="width: 5%; text-align: center; border:0;">
{% revision info=info path=root to_revision=to_revision.number %}
        </div>
        <div class="cell" style="width: 50%; text-align: right; border:0;">
        {% if to_revision.next %}
{% revision info=info path=root to_revision=to_revision.next.number %}
        {% else %}
        None
        {% endif %}
        ❯
        </div>
    </div>
</div>
<br />
<br />

    <fieldset>
        <div>
            <label>Project</label>
            <div>
                <span class="code">
                    <a href="{% url project project=project.code %}">{{project}}</a>
                </span>
            </div>
        </div>
        <div>
            <label>Author</label>
            <div>
                {% author to_revision.author %}
            </div>
        </div>
        <div>
            <label>Commited at</label>
            <div>
                {{to_revision.time_commit}} ({{to_revision.time_commit|timesince}} ago)
            </div>
        </div>
    </fieldset>

    <h3>Revision Log</h3>
    <p class="code"
        style="
            border-width: 0.1em 0 0.1em 0;
            border-style: solid;
            border-color: #d0d0d0;
            margin: 0;
            padding: 0.5em;
            white-space: pre-wrap;
            word-wrap: break-word;
        "
    >{{to_revision.log}}</p>

    <a name="committed_files"></a>
    <h3>
        Committed Files
    </h3>

    <div class="table">
        {% for file in revision_files %}
{% with file|get_revision_file_by_number:to_revision.number as revision_file %}
            <div class="row {{revision_file.kind}}">
                <div class="cell">
{% revision info=info link=file.abspath path=file to_revision=to_revision.number %}
                </div>
                <div class="cell" style="width: 1%; font-style: italic;">
                    <div style="min-width: 5em;">
                    {{revision_file.kind_verbose}}
                    </div>
                </div>
                <div class="cell" style="width: 9%;">
                    <div class="table noborder" style="width: 12em;"
                    ><div class="row">
                        <div class="cell align-right" style="width: 40%; padding: 0;">
{% revision info=info to_revision=revision_file.previous.revision.number %}
                        </div>
                        <div class="cell align-center" style="width: 20%; padding: 0;">❯</div>
                        <div class="cell align-left" style="width: 40%; padding: 0;">
{% revision info=info to_revision=revision_file.revision.number %}
                        </div>
                    </div></div>
                </div>
            </div>
{% endwith %}
        {% endfor %}
    </div>

<a name="latest_dialog"></a>
<h3>Latest Dialogs</h3>
{% for message in page.object_list %}
    {% with message.message as object %}
    {% include "dialog/_dialogs.html" %}
    {% endwith %}
{% endfor %}
{% endblock %}
